﻿<UserControl x:Class="CardPlay.Client.Views.GameHistoryView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity" mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="500">
    <Grid>
        <Grid.Resources>
            <ResourceDictionary>
                <ResourceDictionary.MergedDictionaries>
                    <ResourceDictionary Source="/Themes/DataGrid.xaml" />
                </ResourceDictionary.MergedDictionaries>
            </ResourceDictionary>
        </Grid.Resources>
        <DataGrid x:Name="HistoryTable" ItemsSource="{Binding Data}" IsReadOnly="true" Style="{StaticResource DataGridStyle}" >

            <i:Interaction.Triggers>
                <i:EventTrigger EventName="MouseDoubleClick">
                    <i:InvokeCommandAction Command="{Binding RetryGame}" 
                                                   CommandParameter="{Binding ElementName=HistoryTable, Path=SelectedItem, Mode=OneWay}" />
                </i:EventTrigger>
            </i:Interaction.Triggers>

            <DataGrid.GroupStyle>
                <GroupStyle ContainerStyle="{StaticResource GroupItemStyle}"/>
            </DataGrid.GroupStyle>

            <DataGrid.Columns>
                <DataGridTextColumn Header="Date" MinWidth="85" Binding="{Binding TimeStarted, StringFormat=d}" CellStyle="{StaticResource RightAlignCellStyle}" />
                <DataGridTextColumn Header="Start" MinWidth="65" Binding="{Binding TimeStarted, StringFormat=t}" HeaderStyle="{StaticResource CenterAlignHeaderStyle}" CellStyle="{StaticResource RightAlignCellStyle}" CanUserReorder="False"  />
                <DataGridTextColumn Header="Time" MinWidth="65" Binding="{Binding Duration}" HeaderStyle="{StaticResource CenterAlignHeaderStyle}" CellStyle="{StaticResource CenterAlignCellStyle}" />
                <DataGridTextColumn Header="Outcome" MinWidth="70" Binding="{Binding Outcome}" HeaderStyle="{StaticResource CenterAlignHeaderStyle}" CellStyle="{StaticResource CenterAlignCellStyle}" />
                <DataGridTextColumn Header="Moves" MinWidth="65" Binding="{Binding TotalMoves}" HeaderStyle="{StaticResource CenterAlignHeaderStyle}" CellStyle="{StaticResource RightAlignCellStyle}" />
                <DataGridTextColumn Header="Game Number" MinWidth="120" Binding="{Binding GameNumber}" HeaderStyle="{StaticResource CenterAlignHeaderStyle}" CellStyle="{StaticResource RightAlignCellStyle}" />
            </DataGrid.Columns>

        </DataGrid>
    </Grid>
</UserControl>
